package com.zjy.spts.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.Map;

/**
 * Created by zjy629 on 2018/4/19.
 */
@Controller
@RequestMapping

public class HomeController {
    private static Logger logger = LoggerFactory.getLogger(HomeController.class);
    @RequestMapping(value="/index")
    public String hello(HttpSession session,Map<String,Object> map){
       String name  =this.getName(session);
       logger.info("aaaaaaaaaaaaaaa");
        logger.info("name2:"+name);
       if(name != null){
           map.put("name",name);
       }
        return "index";
    }

    @RequestMapping(value="/checkSessionName")
    public String  getName(HttpSession session){
       Object obj =  session.getAttribute("name");
       if(obj instanceof  String){
           String name = (String)obj;
           logger.info("name1:"+name+"-----");
           return  name;
       }else{
           return  null;
       }
    }

    @RequestMapping(value="/tabs")
    public String tabs(HttpSession session,Map<String,Object> map){
        String name  =this.getName(session);
        logger.info("name2:"+name);
        if(name != null){
            map.put("name",name);
        }
        return "tabs";
    }
    @RequestMapping(value="/widget")
    public String widget(HttpSession session,Map<String,Object> map){
        String name  =this.getName(session);
        logger.info("name2:"+name);
        if(name != null){
            map.put("name",name);
        }
        return "widget";
    }

    @RequestMapping(value="/calender")
    public String calender(HttpSession session,Map<String,Object> map){
        String name  =this.getName(session);
        logger.info("name2:"+name);
        if(name != null){
            map.put("name",name);
        }
        return "calender";
    }
    @RequestMapping(value="/forms")
    public String forms(HttpSession session,Map<String,Object> map){
        String name  =this.getName(session);
        logger.info("name2:"+name);
        if(name != null){
            map.put("name",name);
        }
        return "forms";
    }

    @RequestMapping(value="/validation")
    public String validation(HttpSession session,Map<String,Object> map){
        String name  =this.getName(session);
        logger.info("name2:"+name);
        if(name != null){
            map.put("name",name);
        }
        return "validation";
    }

    @RequestMapping(value="/table")
    public String table(HttpSession session,Map<String,Object> map){
        String name  =this.getName(session);
        logger.info("name2:"+name);
        if(name != null){
            map.put("name",name);
        }
        return "table";
    }
    @RequestMapping(value="/buttons")
    public String buttons(HttpSession session,Map<String,Object> map){
        String name  =this.getName(session);
        logger.info("name2:"+name);
        if(name != null){
            map.put("name",name);
        }
        return "buttons";
    }
    @RequestMapping(value="/typography")
    public String typography(HttpSession session,Map<String,Object> map){
        String name  =this.getName(session);
        logger.info("name2:"+name);
        if(name != null){
            map.put("name",name);
        }
        return "typography";
    }

    @RequestMapping(value="/404")
    public String s404s(HttpSession session,Map<String,Object> map){
        String name  =this.getName(session);
        logger.info("name2:"+name);
        if(name != null){
            map.put("name",name);
        }
        return "404";
    }
    @RequestMapping(value="/sign")
    public String sign(HttpSession session,Map<String,Object> map){
        String name  =this.getName(session);
        logger.info("name2:"+name);
        if(name != null){
            map.put("name",name);
        }
        return "sign";
    }

    @RequestMapping(value="/profile")
    public String profile(HttpSession session,Map<String,Object> map){
        String name  =this.getName(session);
        logger.info("name2:"+name);
        if(name != null){
            map.put("name",name);
        }
        return "profile";
    }
    @RequestMapping(value="/inbox")
    public String inbox(HttpSession session,Map<String,Object> map){
        String name  =this.getName(session);
        logger.info("name2:"+name);
        if(name != null){
            map.put("name",name);
        }
        return "inbox";
    }
    @RequestMapping(value="/compose")
    public String compose(HttpSession session,Map<String,Object> map){
        String name  =this.getName(session);
        logger.info("name2:"+name);
        if(name != null){
            map.put("name",name);
        }
        return "compose";
    }
    @RequestMapping(value="/editor")
    public String editor(HttpSession session,Map<String,Object> map){
        String name  =this.getName(session);
        logger.info("name2:"+name);
        if(name != null){
            map.put("name",name);
        }
        return "editor";
    }
    @RequestMapping(value="/grids")
    public String grids(HttpSession session,Map<String,Object> map){
        String name  =this.getName(session);
        logger.info("name2:"+name);
        if(name != null){
            map.put("name",name);
        }
        return "grids";
    }
    @RequestMapping(value="/media")
    public String media(HttpSession session,Map<String,Object> map){
        String name  =this.getName(session);
        logger.info("name2:"+name);
        if(name != null){
            map.put("name",name);
        }
        return "media";
    }
    @RequestMapping(value="/chart")
    public String chart(HttpSession session,Map<String,Object> map){
        String name  =this.getName(session);
        logger.info("name2:"+name);
        if(name != null){
            map.put("name",name);
        }
        return "chart";
    }

    @RequestMapping(value="/map")
    public String map(HttpSession session,Map<String,Object> map){
        String name  =this.getName(session);
        logger.info("name2:"+name);
        if(name != null){
            map.put("name",name);
        }
        return "map";
    }

    @RequestMapping(value="/graph")
    public String graph(HttpSession session,Map<String,Object> map){
        String name  =this.getName(session);
        logger.info("name2:"+name);
        if(name != null){
            map.put("name",name);
        }
        return "graph";
    }
    @RequestMapping(value="/project")
    public String project(HttpSession session,Map<String,Object> map){
        String name  =this.getName(session);
        logger.info("name2:"+name);
        if(name != null){
            map.put("name",name);
        }
        return "project";
    }
    @RequestMapping(value="/ribbon")
    public String ribbon(HttpSession session,Map<String,Object> map){
        String name  =this.getName(session);
        logger.info("name2:"+name);
        if(name != null){
            map.put("name",name);
        }
        return "ribbon";
    }

    @RequestMapping(value="/blank")
    public String blank(HttpSession session,Map<String,Object> map){
        String name  =this.getName(session);
        logger.info("name2:"+name);
        if(name != null){
            map.put("name",name);
        }
        return "blank";
    }
    @RequestMapping(value="/500")
    public String s500s(HttpSession session,Map<String,Object> map){
        String name  =this.getName(session);
        logger.info("name2:"+name);
        if(name != null){
            map.put("name",name);
        }
        return "500";
    }
}
